package com.d3works.apps.purchase.service;

import com.d3works.apps.base.db.Product;
import com.d3works.apps.base.db.repo.ProductRepository;
import com.d3works.apps.base.db.repo.ProductVariantRepository;
import com.d3works.apps.base.service.ProductCompanyService;
import com.d3works.apps.base.service.ProductServiceImpl;
import com.d3works.apps.base.service.ProductVariantService;
import com.d3works.apps.base.service.administration.SequenceService;
import com.d3works.apps.base.service.app.AppBaseService;
import com.google.inject.Inject;

public class ProductServicePurchaseImpl extends ProductServiceImpl {

  @Inject
  public ProductServicePurchaseImpl(
      ProductVariantService productVariantService,
      ProductVariantRepository productVariantRepo,
      SequenceService sequenceService,
      AppBaseService appBaseService,
      ProductRepository productRepo,
      ProductCompanyService productCompanyService) {
    super(
        productVariantService,
        productVariantRepo,
        sequenceService,
        appBaseService,
        productRepo,
        productCompanyService);
  }

  @Override
  public void copyProduct(Product product, Product copy) {
    super.copyProduct(product, copy);

    if (appBaseService.isApp("purchase-request")) {
      copy.setSupplierCatalogList(null);
    }
  }
}
